package cn.gson.crm.controller.student;

import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.StudentDao;
import cn.gson.crm.model.entity.Dept;
import cn.gson.crm.model.entity.Student;

/**
 * 处理查看班级里的学生的ajax
 */
@WebServlet("/student/assignajax")
public class StudentAssignAjaxServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private StudentDao studentDao=new StudentDao();

	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String classid=request.getParameter("classid");
//		System.out.println(classid+" classid");
		
		List<Student> studentList=studentDao.getAllClassMateByClassId(classid);
		response.setContentType("application/json;charset=utf-8");

		// 把结果转换成JSON字符串
		String jsonStr = JSONArray.toJSONString(studentList);
		// 输出结果
		response.getWriter().append(jsonStr);
		
	}

}
